// =======================================================================
// 
//       Filename:  page.cpp
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  27.03.2010 19:37:30
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dominik 'domachine' Burgdörfer (-), dominik.burgdoerfer@googlemail.com
//        Company:  -
// 
// =======================================================================

#include "page.hpp"
#include <fstream>

namespace webplodder {
    Page::Page(const boost::filesystem::path& sourcePath,
               const boost::filesystem::path& outputPath)
        : std::map<std::string,std::string>(), mSourcePath(sourcePath),
          mOutputPath(outputPath)
    {
    }

    void Page::parse()
    {
        std::ifstream in(mSourcePath.string().c_str());
        YAML::Parser parser(in);

        YAML::Node doc;

        parser.GetNextDocument(doc);
        YAML::Iterator it;

        std::string key;

        for(it = doc.begin(); it != doc.end(); ++it) {
            it.first() >> key;
            it.second() >> (*this)[key];
        }
    }
    
    boost::filesystem::path Page::sourcePath() const
       
    {
        return mSourcePath;
    }

    boost::filesystem::path Page::outputPath() const
    {
        return mOutputPath;
    }
}
